/* 
 * Copyright 2014 ShangDao.Ltd  All rights reserved.
 * SiChuan ShangDao.Ltd PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * 
 * @BaHeaderAdapter.java  2014年9月10日 下午4:25:21 - Guzhu
 * @author Guzhu
 * @email:muyi126@163.com
 * @version 1.0
 */

package com.android.tiango.baba.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.android.scsd.tiango.R;
import com.android.tiango.baba.entity.SimpleUserModel;
import com.android.tiango.baba.util.ImageLoader;
import com.android.tiango.baba.view.RoundImageView;

public class BaHeaderAdapter extends BaseAdapter{
	private Context context;
	private ArrayList<SimpleUserModel> list;
	private ImageLoader imageLoader;
	public BaHeaderAdapter(Context context,ArrayList<SimpleUserModel> list){
		this.context = context;
		this.list = list;
		imageLoader = new ImageLoader(context, R.drawable.icon);
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public SimpleUserModel getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder;
		SimpleUserModel model = getItem(position);
		if(null==convertView){
			convertView = LayoutInflater.from(context).inflate(R.layout.item_header, null);
			viewHolder = new ViewHolder();
			viewHolder.imageView = (RoundImageView) convertView.findViewById(R.id.iv_IamgeHeader);
			convertView.setTag(viewHolder);
		}
		viewHolder = (ViewHolder) convertView.getTag();
		if(null!=model){
			imageLoader.loadImage(getItem(position).getAvatarUrl(), viewHolder.imageView);
		}
		return convertView;
	}
	
	private class ViewHolder{
		RoundImageView imageView;
		
	}
	
	
	
	

}
